<%@ page import="java.sql.*"%>
<%@ page import="java.io.*"%>
<%!String uid=null;


%>

<%
  FileInputStream fis;
  uid=(String)session.getAttribute("id");
  String path=request.getParameter("propict");
  
  try{
	  Class.forName("com.mysql.jdbc.Driver");
	    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/kbcssdb","root","mysql");
	    File image=new File(path);
	    PreparedStatement ps=con.prepareStatement("insert into image(userid,pic) values(?,?)");
        ps.setString(1,uid);
        fis=new FileInputStream(image);
  
        ps.setBinaryStream(2, (InputStream)fis, (int)(image.length()));
  int s = ps.executeUpdate();

  if(s>0) {
 %>
 <b><font color="Blue">
 <% out.println("Image Uploaded successfully !"); %>
 </font></b>
 <%
 }
else {
out.println("unsucessfull to upload image.");
  }
  con.close();
  ps.close();
}catch(Exception ex){
out.println("Error in connection : "+ex);

}

%>
<%=uid %><%=path%>